package com.ruoyi.wechat.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.Collect;
import com.ruoyi.wechat.service.ICollectService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收藏表Controller
 *
 */
@RestController
@RequestMapping("/wechatt/collect")
public class WxCollectController extends BaseController{
    @Autowired
    private ICollectService collectService;

    /**
     * 查询收藏表列表
     */

//    @GetMapping("/list")
//    public TableDataInfo list(Collect collect)
//    {
//        startPage();
//        List<Collect> list = collectService.selectCollectList(collect);
//        return getDataTable(list);
//    }
    @GetMapping("/list")
    public TableDataInfo listuserId(@RequestParam(required = false) Collect collect) {
        // 这里添加你的业务逻辑，例如数据库操作
        List<Collect> list = collectService.selectCollectList(collect);
        return getDataTable(list);
    }


    /**
     * 获取收藏表详细信息
     */

    @GetMapping(value = "/{collectId}")
    public AjaxResult getInfo(@PathVariable("collectId") String collectId)
    {
        return success(collectService.selectCollectByCollectId(collectId));
    }
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfouserId(@PathVariable("userId") String userId)
    {
        return success(collectService.selectCollectByuserId(userId));
    }

    /**
     * 新增收藏表
     */

    @Log(title = "收藏表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Collect collect)
    {
        return success(collectService.insertCollect(collect));
    }

    /**
     * 修改收藏表
     */

    @Log(title = "收藏表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Collect collect)
    {
        return toAjax(collectService.updateCollect(collect));
    }

    /**
     * 删除收藏表
     */

    @Log(title = "收藏表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{collectId}")
    public AjaxResult remove(@PathVariable String collectId)
    {
        return toAjax(collectService.deleteCollectByCollectId(collectId));
    }
}
